﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Filter;

namespace COFE.Core.Utils
{
    /// <summary>
    /// Parse/generate property string to/from Filter
    /// </summary>
    public interface IFilterParser<T> where T : IFilter
    {
        /// <summary>
        /// Uses to serialize the properties to string.
        /// </summary>
        IPropertySerializer Serializer { get; }

        string FilterToFilterString(IEnumerable<IFilter> filters);        
    }

    public static class IFilterParserExtension
    {
        public static string FilterToFilterString<T>(this IFilterParser<T> parser,
            IFilter filter) where T : IFilter
        {
            return parser.FilterToFilterString(
                new List<IFilter>() { 
                    filter
                });
        }
    }
}
